*	************************************************************************
* 	File-Name: 		Tables.do
*	Log-file:		----JOP_tables_logfiles.log
*
*	Author: 		Aycan Katitas
*
*	Data Used:  	anes12120analysisIV.dta
*
*	Purpose:   		.do file for estimating main and appendix table results
*	
*   Date Updated: July 2024
*	************************************************************************

clear
set more off

cd "/Users/aycankatitas/Desktop/Git/chinagfdi"

use "data/anes1220analysisIV.dta", clear

quietly do "codebook/vars_codebook.do"



************
* MAIN TEXT
************


****************************************************************************
**Table 1: Chinese GFDI and Threat Perceptions: Two-Stage Least Squares Estimates
****************************************************************************

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo main1
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state)
eststo main2 
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo main3
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log), partial(i.sample_state) cluster(sample_state)
eststo main4
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace
}


esttab main1 main2 main3 main4 using output/table1.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year ind dist, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects" "Individual Level Controls" "District Level Controls"))  ///
	keep(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log chinafdidum) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log chinafdidum) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions: Two Stage Least-Squares Estimates")


************
* APPENDIX
************

****************************************************************************
**Table A1: Summary Statistics and Data Sources for Main Variables
****************************************************************************

*** Note: Data sources are filled in manually. 
estpost tabstat chinaect ch_cty_d ch_ctyval_d ch_ctyjobs_d mano_d othernoiv_d otherjobsiv_d othervaliv_d nationalism education econoutlook party age gender unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d pop_ivbase_d presvote per_urban percollege_ivbase_d unemploy_diff_d chinesepop_diff_d, c(stat) stat(mean sd min max p25 p75)

esttab . using output/tablea1.tex, cells("mean(fmt(a3)) sd min max") replace nonumber ///
   nomtitle nonote label collabels("Mean" "Std. Deviation" "Min" "Max") ///
   booktabs ///
   title("Summary Statistics and Data Sources for Main Variables")

   
est clear 

****************************************************************************
**Table A3: First Stage Regression Results
****************************************************************************


eststo clear

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log),  partial(i.sample_state) cluster(sample_state) first savefirst savefprefix(st1)
eststo
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local fstat "39.43", replace

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state) first savefirst savefprefix(st2)
eststo
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local fstat "56.21", replace

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state) first savefirst savefprefix(st3)
eststo
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local fstat "57.98", replace

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect2
ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log), partial(i.sample_state) cluster(sample_state) first savefirst savefprefix(st4)
eststo
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local fstat "41.93", replace
}

esttab st1* st2* st3* st4* using output/tablea3.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year fstat, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"  "F Statistics"))  ///
	drop(*.year) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(z_log zval_log zjobs_log) ///
	mgroups("\shortstack{China GFDI \\ No (logged)}" "\shortstack{China GFDI \\ Value (logged)}" "\shortstack{China GFDI \\ Jobs (logged)}" "\shortstack{China GFDI == 1}", pattern(1 1 1 1)) mlabels(none) ///
	title("First Stage Regression Results")
	
** Note: Manually filled in F-statistics in the appendix table.	
** uncomment the following code to calculate Montiel-Pflueger robust weak instrument test F statistics mentioned in the table and text
/*
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log),  partial(i.sample_state) cluster(sample_state) 
weakivtest 
ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state) first savefirst savefprefix(st2)
weakivtest
ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state) first savefirst savefprefix(st3)
weakivtest
ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log), partial(i.sample_state) cluster(sample_state) first savefirst savefprefix(st4)
weakivtest
*/


****************************************************************************
**Table A4: Chinese GFDI and Threat Perceptions: Two Stage Least-Squares Estimates - with Controls
****************************************************************************


eststo clear 

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo full1
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state)
eststo full2 
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo full3
estadd local state "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log), partial(i.sample_state) cluster(sample_state)
eststo full4
estadd local state "Yes", replace
estadd local year "Yes", replace
}


esttab full1 full2 full3 full4 using output/tablea4.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"))  ///
	drop(*.year) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log chinafdidum) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions: Two Stage Least-Squares Estimates - with Controls")
	
****************************************************************************
**Table A5: Chinese GFDI and Threat Perceptions, Interaction with ANES Survey Year
****************************************************************************
 
eststo clear 

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (c.chinanoiv_d_log##i.year= c.z_log##i.year), partial(i.sample_state) cluster(sample_state)
eststo year1
estadd local state "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (c.chinavaliv_d_log##i.year= c.zval_log##i.year), partial(i.sample_state) cluster(sample_state)
eststo year2
estadd local state "Yes", replace
ivreg2 `y' `indcont' `distcont' `f' (c.chinajobsiv_d_log##i.year= c.zjobs_log##i.year), partial(i.sample_state) cluster(sample_state)
eststo year3
estadd local state "Yes", replace
}

esttab year1 year2 year3 using output/tablea5.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state, fmt(%7.0fc)  labels("Observations" "State Fixed Effects"))  ///
	booktabs nonotes nogaps compress ///
	interaction(" $\times$ ") ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log *year *.year#c.chinanoiv_d_log  *.year#c.chinavaliv_d_log *.year#c.chinajobsiv_d_log) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, Interaction with ANES Survey Year")

* run this for Figure A5 - results stored in marginsjobsyear.csvs	
*ivreg2 chinaect nationalism education econoutlook party age gender unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log i.sample_state i.year (c.chinajobsiv_d_log##i.year= c.zjobs_log##i.year), cluster(sample_state)
*margins, at(chinajobsiv_d_log=(-2(1)7) year=(1 2))

****************************************************************************
**Table A6: Chinese GFDI and Threat Perceptions, by ANES Survey Year
****************************************************************************
eststo clear 

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect2
qui{
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log) if year ==1, partial(i.sample_state) cluster(sample_state)
eststo y12a
estadd local state "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log) if year==1, partial(i.sample_state) cluster(sample_state)
eststo y12b
estadd local state "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log) if year==1, partial(i.sample_state) cluster(sample_state)
eststo y12c
estadd local state "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log) if year==1, partial(i.sample_state) cluster(sample_state)
eststo y12d
estadd local state "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log) if year ==2, partial(i.sample_state) cluster(sample_state)
eststo y20a
estadd local state "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log) if year==2, partial(i.sample_state) cluster(sample_state)
eststo y20b
estadd local state "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log) if year==2, partial(i.sample_state) cluster(sample_state)
eststo y20c
estadd local state "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log) if year==2, partial(i.sample_state) cluster(sample_state)
eststo y20d
estadd local state "Yes", replace
}

esttab y12* y20* using output/tablea6.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state, fmt(%7.0fc)  labels("Observations" "State Fixed Effects"))  ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log chinafdidum) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, by ANES Survey Year")

****************************************************************************
**Table A7: Chinese GFDI and Threat Perceptions, by Media Reports
****************************************************************************
eststo clear 

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (medianoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo ma1
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (nomedianoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo ma2
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (mediavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state)
eststo mb1 
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (nomediavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state)
eststo mb2
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (mediajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo mc1
estadd local state "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (nomediajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo mc2
estadd local state "Yes", replace
estadd local year "Yes", replace
}


esttab ma1 ma2 mb1 mb2 mc1 mc2 using output/tablea7.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"))  ///
	drop(*.year) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(medianoiv_d_log nomedianoiv_d_log mediavaliv_d_log nomediavaliv_d_log mediajobsiv_d_log nomediajobsiv_d_log) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, by Media Reports")

****************************************************************************
**Table A8: Chinese GFDI and Threat Perceptions, Controlling for News Consumption and Manufacturing Occupation
***************************************************************************

* Code in TableA8.do file

****************************************************************************
**Table A9: Chinese GFDI and Threat Perceptions, by Nationalism
***************************************************************************
** Figure A6 by Nationalism
eststo clear 

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 nationalism education econoutlook party age gender unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log i.sample_state i.year (chinanoiv_d_log = z_log), cluster(sample_state)  partial(i.sample_state) 
eststo nat0
estadd local state "Yes", replace
estadd local year "Yes", replace
ivreg2  `y' `indcont' `distcont' `f' (c.chinanoiv_d_log##c.nationalism= c.z_log##c.nationalism), cluster(sample_state)  partial(i.sample_state) 
eststo nat1
estadd local state "Yes", replace
estadd local year "Yes", replace
ivreg2 `y' `indcont' `distcont' `f' (c.chinavaliv_d_log##c.nationalism= c.zval_log##c.nationalism), cluster(sample_state)  partial(i.sample_state) 
eststo nat2
estadd local state "Yes", replace
estadd local year "Yes", replace	
ivreg2 `y' `indcont' `distcont' `f' (c.chinajobsiv_d_log##c.nationalism= c.zjobs_log##c.nationalism), cluster(sample_state)  partial(i.sample_state) 
eststo nat3
estadd local state "Yes", replace
estadd local year "Yes", replace
}

esttab nat0 nat1 nat2 nat3 using output/tablea9.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"))  ///
	drop(*.year) ///
	booktabs nonotes nogaps compress ///
	interaction(" $\times$ ") ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log chinajobsiv_d_log *nationalism nationalism#c.chinanoiv_d_log  nationalism#c.chinavaliv_d_log nationalism#c.chinajobsiv_d_log) ///
	nomtitle mgroups("Nationalism" "China Threat == 1", pattern(1 1 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, by Nationalism")

* run this for Figure A6 - results stored in natmargins.csvs	
*ivreg2 chinaect nationalism education econoutlook party age gender unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log i.sample_state i.year (c.chinajobsiv_d_log##c.nationalism= c.zjobs_log##c.nationalism), cluster(sample_state)
*margins, at(chinajobsiv_d_log=(-2(1)7) nationalism=(0 2 4))


****************************************************************************
**Table A10: Chinese Mergers and Acquisitions and Threat Perceptions - Placebo Test
***************************************************************************

eststo clear
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log mano_d_log
local f i.sample_state i.year
local y chinaect
qui{
reg `y' `indcont' `distcont' `f', cluster(sample_state)
eststo ols
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo gma1
estadd local state "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state)
eststo gma2
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo gma3
estadd local state "Yes", replace
estadd local year "Yes", replace
}

esttab ols gma1 gma2 gma3 using output/tablea10.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"))  ///
	drop(*sample_state *.year) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(mano_d_log chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese Mergers and Acquisitions and Threat Perceptions - Placebo Test")

****************************************************************************
**Table A11: Other East Asian GFDI and Threat Perceptions - Placebo Test
***************************************************************************


eststo clear 
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (asianoiv_d_log= asiaz_log), partial(i.sample_state) cluster(sample_state)
eststo asia1
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (asiavaliv_d_log= asiazval_log), partial(i.sample_state) cluster(sample_state)
eststo asia2 
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (asiajobsiv_d_log= asiazjobs_log), partial(i.sample_state) cluster(sample_state)
eststo asia3
estadd local state "Yes", replace
estadd local year "Yes", replace
}


esttab asia1 asia2 asia3 using output/tablea11.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"))  ///
	drop(*.year) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(asianoiv_d_log asiavaliv_d_log  asiajobsiv_d_log) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Other East Asian GFDI and Threat Perceptions - Placebo Test")
	


****************************************************************************
**Table A12: All Other GFDI and Threat Perceptions - Placebo Test
***************************************************************************


eststo clear 
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (nonchinanoiv_d_log= nonchinaz_log), partial(i.sample_state) cluster(sample_state)
eststo other1
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (nonchinavaliv_d_log= nonchinazval_log), partial(i.sample_state) cluster(sample_state)
eststo other2 
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (nonchinajobsiv_d_log= nonchinazjobs_log), partial(i.sample_state) cluster(sample_state)
eststo other3
estadd local state "Yes", replace
estadd local year "Yes", replace
}


esttab other1 other2 other3 using output/tablea12.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"))  ///
	drop(*.year) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(nonchinanoiv_d_log nonchinavaliv_d_log nonchinajobsiv_d_log) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("All Other GFDI and Threat Perceptions - Placebo Test")


****************************************************************************
**Table A13: Chinese GFDI and Military Threat Perceptions - Placebo Test
***************************************************************************

eststo clear 

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state
local y chinamil
qui{
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log) if year==1, partial(i.sample_state) cluster(sample_state)
eststo mil1
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log) if year==1, partial(i.sample_state) cluster(sample_state)
eststo mil2
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log) if year==1, partial(i.sample_state) cluster(sample_state)
eststo mil3
estadd local state "Yes", replace
estadd local year "Yes", replace
}

esttab mil1 mil2 mil3 using output/tablea13.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state, fmt(%7.0fc)  labels("Observations" "State Fixed Effects"))  ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log) ///
	nomtitle mgroups("China Military Threat == 1", pattern(1 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Military Threat Perceptions - Placebo Test")


****************************************************************************
**Table A14: Chinese GFDI and Threat Perceptions, Additional Controls
***************************************************************************

eststo clear 

local indcont nationalism education econoutlook party age gender i.race 
local indcont2 ideology income_grp
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local othercont pop_ivbase_d_log presvote percollege_ivbase_d unemploy_diff_d chinesepop_diff_d 
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `indcont2' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo socio1
estadd local state "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `indcont2' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state) 
eststo socio2
estadd local state "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `indcont2' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo socio3
estadd local state "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' `othercont' othernoiv_d_log  c.per_urban##i.year (chinanoiv_d_log c.tradeshock_d##i.year= z_log c.tradeshocki_d##i.year), partial(i.sample_state) cluster(sample_state) 
eststo ins1
estadd local state "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' `othercont' othervaliv_d_log  c.per_urban##i.year (chinavaliv_d_log c.tradeshock_d##i.year= zval_log c.tradeshocki_d##i.year), partial(i.sample_state) cluster(sample_state) 
eststo ins2
estadd local state "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' `othercont' otherjobsiv_d_log  c.per_urban##i.year (chinajobsiv_d_log c.tradeshock_d##i.year= zjobs_log c.tradeshocki_d##i.year), partial(i.sample_state) cluster(sample_state)
eststo ins3
estadd local state "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace
}

esttab socio1 socio2 socio3 ins1 ins2 ins3 using output/tablea14.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state ind dist, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Individual-level Controls" "District-level Controls"))  ///
	drop(nationalism education econoutlook party age gender *.race unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log) ///
	booktabs nonotes nogaps ///
	interaction(" $\times$ ") ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log ideology income_grp tradeshock_d *year *.year#c.tradeshock_d pop_ivbase_d_log presvote percollege_ivbase_d unemploy_diff_d chinesepop_diff_d othernoiv_d_log othervaliv_d_log otherjobsiv_d_log) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, Additional Controls")
	
****************************************************************************
**Table A15: Chinese GFDI and Threat Perceptions, Excluding Most Common Industries
***************************************************************************

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (it_chinanoiv_d_log= it_z_log), partial(i.sample_state) cluster(sample_state)
eststo inda1
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (it_chinavaliv_d_log= it_zval_log), partial(i.sample_state) cluster(sample_state)
eststo inda2
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (it_chinajobsiv_d_log= it_zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo inda3
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (ind_chinanoiv_d_log= ind_z_log), partial(i.sample_state) cluster(sample_state)
eststo indb1
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local ind "Yes", replace
estadd local dist "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (ind_chinavaliv_d_log= ind_zval_log), partial(i.sample_state) cluster(sample_state)
eststo indb2
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (ind_chinajobsiv_d_log= ind_zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo indb3
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (auto_chinanoiv_d_log= auto_z_log), partial(i.sample_state) cluster(sample_state)
eststo indc1
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (auto_chinavaliv_d_log= auto_zval_log), partial(i.sample_state) cluster(sample_state)
eststo indc2
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (auto_chinajobsiv_d_log= auto_zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo indc3
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 
}


esttab inda1 inda2 inda3 indb1 indb2 indb3 indc1 indc2 indc3 using output/tablea15.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year ind dist, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects" "Individual Level Controls" "District Level Controls"))  ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	keep(it_chinanoiv_d_log it_chinavaliv_d_log it_chinajobsiv_d_log ind_chinanoiv_d_log ind_chinavaliv_d_log ind_chinajobsiv_d_log auto_chinanoiv_d_log auto_chinavaliv_d_log auto_chinajobsiv_d_log) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0 0 0 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, Excluding Most Common Industries")

****************************************************************************
**Table A16: Chinese GFDI and Threat Perceptions, Different Timing of Announcements
***************************************************************************

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log_8mo= z_log_8mo), partial(i.sample_state) cluster(sample_state)
eststo time1a
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace  

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log_8mo= zval_log_8mo), partial(i.sample_state) cluster(sample_state)
eststo time1b
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log_8mo= zjobs_log_8mo), partial(i.sample_state) cluster(sample_state)
eststo time1c
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log_1y= z_log_1y), partial(i.sample_state) cluster(sample_state)
eststo time2a
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace  

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log_1y= zval_log_1y), partial(i.sample_state) cluster(sample_state)
eststo time2b
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log_1y= zjobs_log_1y), partial(i.sample_state) cluster(sample_state)
eststo time2c
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log_3y= z_log_3y), partial(i.sample_state) cluster(sample_state)
eststo time3a
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace  

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log_3y= zval_log_3y), partial(i.sample_state) cluster(sample_state)
eststo time3b
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log_3y= zjobs_log_3y), partial(i.sample_state) cluster(sample_state)
eststo time3c
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 
}

esttab  using output/tablea16.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year ind dist, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects" "Individual Level Controls" "District Level Controls"))  ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	keep(chinanoiv_d_log_8mo chinavaliv_d_log_8mo chinajobsiv_d_log_8mo chinanoiv_d_log_1y chinavaliv_d_log_1y chinajobsiv_d_log_1y chinanoiv_d_log_3y chinavaliv_d_log_3y chinajobsiv_d_log_3y) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0 0 0 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, Different Timing of Announcements")
	
****************************************************************************
**Table A17: Chinese GFDI and Threat Perceptions, Alternative Coding of the Dependent Variable
***************************************************************************
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
qui{
ivreg2 chinaect3 `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo dva1
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 chinaect3 `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state)
eststo dva2
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 chinaect3 `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo dva3
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 chinaect2 `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo dvb1
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 chinaect2 `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state)
eststo dvb2
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 chinaect2 `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo dvb3
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 china_sd `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state)
eststo dvc1
estadd local state "Yes", replace
estadd local year "Yes", replace 
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 china_sd `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state)
eststo dvc2
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

ivreg2 china_sd `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state)
eststo dvc3
estadd local state "Yes", replace
estadd local year "Yes", replace
estadd local ind "Yes", replace
estadd local dist "Yes", replace 

}

esttab dva1 dva2 dva3 dvb1 dvb2 dvb3 dvc1 dvc2 dvc3 using output/tablea17.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year ind dist, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects" "Individual Level Controls" "District Level Controls"))  ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	keep(chinanoiv_d_log chinavaliv_d_log chinajobsiv_d_log) ///
	mlabels(none)  mgroups("China Threat == 1" "\shortstack{China Threat \\ Three Categories}" "\shortstack{China Threat \\ Rescaled}" , pattern(1 0 0 1 0 0 1 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, Alternative Coding of the Dependent Variable")

****************************************************************************
**Table A18: Chinese GFDI and Threat Perceptions: Two Stage Least-Squares Estimates - District Clustered Standard Errors
***************************************************************************
eststo clear 

local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect

qui{
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(cdids)
eststo clus1
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(cdids)
eststo clus2 
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(cdids)
eststo clus3
estadd local state "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log), partial(i.sample_state) cluster(cdids)
eststo clus4
estadd local state "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(cdids year)
eststo clus5
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(cdids year)
eststo clus6 
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(cdids year)
eststo clus7
estadd local state "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log), partial(i.sample_state) cluster(cdids year)
eststo clus8
estadd local state "Yes", replace
estadd local year "Yes", replace
}


esttab clus* using output/tablea18.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"))  ///
	drop(*.year) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log chinafdidum) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions: Two Stage Least-Squares Estimates - District Clustered Standard Errors")

****************************************************************************
**Table A19: Chinese GFDI and Threat Perceptions: Two Stage Least-Squares Estimates - State and District Fixed Effects
***************************************************************************
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local f2 i.cdids i.year
local y chinaect

qui{
ivreg2 `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log), partial(i.sample_state) cluster(sample_state year)
eststo sy1
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), partial(i.sample_state) cluster(sample_state year)
eststo sy2
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), partial(i.sample_state) cluster(sample_state year)
eststo sy3
estadd local state "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f' (chinafdidum= z_log), partial(i.sample_state) cluster(sample_state year)
eststo sy4
estadd local state "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f2' (chinanoiv_d_log= z_log), partial(i.cdids) cluster(cdids year)
eststo cy1
estadd local cdids "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f2' (chinavaliv_d_log= zval_log), partial(i.cdids) cluster(cdids year)
eststo cy2 
estadd local cdids "Yes", replace
estadd local year "Yes", replace 

ivreg2 `y' `indcont' `distcont' `f2' (chinajobsiv_d_log= zjobs_log), partial(i.cdids) cluster(cdids year)
eststo cy3
estadd local cdids "Yes", replace
estadd local year "Yes", replace

ivreg2 `y' `indcont' `distcont' `f2' (chinafdidum= z_log), partial(i.cdids) cluster(cdids year)
eststo cy4
estadd local cdids "Yes", replace
estadd local year "Yes", replace	
}

esttab sy* cy* using output/tablea19.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state cdids year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "District Fixed Effects" "Year Fixed Effects"))  ///
	drop(*.year) ///
	booktabs nonotes nogaps compress ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log chinafdidum) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions: Two Stage Least-Squares Estimates - State and District Fixed Effects")

****************************************************************************
**Table A20: Chinese GFDI and Threat Perceptions, Probit Results
***************************************************************************
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local y chinaect
qui{
ivprobit `y' `indcont' `distcont' `f' (chinanoiv_d_log= z_log), vce(robust)
eststo p1
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivprobit `y' `indcont' `distcont' `f' (chinavaliv_d_log= zval_log), vce(robust)
eststo p2
estadd local state "Yes", replace
estadd local year "Yes", replace 

ivprobit `y' `indcont' `distcont' `f' (chinajobsiv_d_log= zjobs_log), vce(robust)
eststo p3
estadd local state "Yes", replace
estadd local year "Yes", replace 
}

esttab p1 p2 p3 using output/tablea20.tex, b(3) se(3) wrap label noomitted nobaselevels noconstant replace parentheses stats(N state year, fmt(%7.0fc)  labels("Observations" "State Fixed Effects" "Year Fixed Effects"))  ///
	drop(*.sample_state *.year _cons) ///
	booktabs nonotes nogaps ///
	starlevels( * 0.10 ** 0.05 *** 0.010) ///
	order(chinanoiv_d_log chinavaliv_d_log  chinajobsiv_d_log) ///
	nomtitle mgroups("China Threat == 1", pattern(1 0 0)  ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	title("Chinese GFDI and Threat Perceptions, Probit Results")

** Additional Tables - tF test 
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local f2 i.cdids i.year
local y chinaect
tf `y' `indcont' `distcont' `f' (chinanoiv_d_log = z_log), cluster(sample_state)

** Additional Table - Anderson-Rubin 
local indcont nationalism education econoutlook party age gender i.race
local distcont unemploy_ivbase_d per_manu_ivbase_d perchinese_ivbase_d medinc_ivbase_d_log
local f i.sample_state i.year
local f2 i.cdids i.year
local y chinaect
ivreg2 `y' `indcont' `distcont' `f' (chinafdidum = z_log), cluster(sample_state)
weakiv
weakiv, level(90)

